package main.java.com.leng.service.impl;

import com.leng.dao.UserMapper;
import com.leng.pojo.User;
import com.leng.pojo.UserExample;
import com.leng.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by presoul on 2017/6/13.
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User findUserLogin(String username,String password) {

        UserExample example = new UserExample();

        UserExample.Criteria criteria = example.createCriteria();
        criteria.andUserNameEqualTo(username);
        criteria.andUserPasswordEqualTo(password);

        List<User> list = userMapper.selectByExample(example);
       if (list.get(0)!=null){
           return list.get(0);
       }
       else {
           return new User();
       }
    }
}
